package models;

import java.text.DecimalFormat;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToMany;

import play.data.validation.Required;
import play.db.jpa.Blob;
import play.db.jpa.Model;

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Product extends Model {
	
	@Required
	public String name;
	
	public Blob icon;
	
	public abstract int getCalories();
	
	public abstract double getPrice();

	@ManyToMany
	public List<Ingredient> ingredients;
	
	public String getPriceWithDecimal () {
	    DecimalFormat formatter = new DecimalFormat("###,###,###.00");
	    return formatter.format(this.getPrice());
	}
}
